var { graphql, buildSchema } = require('graphql')

var schema = buildSchema(`
  type Account {
  name: String
  age: Int
  sex: String
  department: String
  }

  type Query {
    hello: String
    accountName: String
    age: Int
    account: Account
  }
`)

var root = {
  hello: () => 'hello world!',
  accountName: 'shanliangdeYWJ',
  age: 25,
  account: () => ({
    name: '李四光',
    age: 18,
    sex: '男',
    department: '科学院'
  })
}

var source = `
  {
    hello
    accountName
    age
    account {
      name
      age
      sex
      department
    }
  }
`

graphql(
  schema,
  source,
  root
).then((response) => {
  console.log(response)
})
